feat: server calculations from DateTime deltas when UseOneMinuteIntervals on (Phase 2)#1542
Merged
renemadsen merged 1 commit intoMay 2, 2026
Conversation
…en UseOneMinuteIntervals on (Phase 2) Phase 2 of the UseOneMinuteIntervals second-precision rollout. When the flag is on, server-side calculations of NettoHours, Flex, SumFlexStart/End, and PaiedOutFlex use DateTime deltas (precise to the second) and write to the *InSeconds int columns as the authoritative source. Legacy double hour fields are derived from the *InSeconds primary via /3600.0. The DateTime fields and *InSeconds columns already exist (no migration needed). The flag-off path is byte-identical to before - existing tests pass unchanged. Adds 8 regression tests covering: flag-on derives from DateTime, flag-on prefers DateTime pause stamp over legacy Pause1Id, the SumFlex chain stays consistent, no-preceding-day case starts at 0, override semantics use the override for flex but actual for netto, PaiedOutFlex follows the same /3600.0 pattern, and a flag-off guard plus an Index integration carve-out test (per the same [Ignore] pattern used in Phases 0 and 1). Plan: /home/rene/.claude/plans/parallel-twirling-balloon.md Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NettoHours,Flex,SumFlexStart/End, andPaiedOutFlexare computed from DateTime deltas (precise to the second) and written to the*InSecondsint columns as the source of truth. Legacydoublehour fields are back-derived via/3600.0.DateTimestamps and*InSecondscolumns already exist (no migration needed).stable— existing tests pass unchanged. Phase 0 (feat: thread UseOneMinuteIntervals flag through calc helpers (Phase 0, no-op) #1540) and Phase 1 (feat: preserve precise DateTime stamps when UseOneMinuteIntervals on (Phase 1) #1541) are merged.What changed
Two new helpers in
PlanRegistrationHelper:ComputeNettoSecondsFromDateTimeShifts(PlanRegistration)— sums(Stop_n_StoppedAt - Start_n_StartedAt).TotalSecondsminus pause seconds across shifts 1..5; falls back to legacy 5-min tick math for shifts without DateTime stamps.ApplyNettoFlexChainSecondPrecision(PlanRegistration, int sumFlexStartInSeconds, bool hasPreTimePlanning)— writesNettoHoursInSeconds,FlexInSeconds,SumFlexStart/EndInSeconds, and back-derives the doubles via/3600.0. Mirrors the flag-off override semantics sign-for-sign.Forks the flex/netto compute at every site:
PlanRegistrationHelper.UpdatePlanRegistrationsInPeriod— 4 SumFlex chain blocksPlanRegistrationHelper.UpdatePlanRegistration— same chainTimePlanningWorkingHoursService.UpdateWorkingHour(1-param personal) — CREATE + UPDATE branchesTimePlanningWorkingHoursService.UpdateWorkingHour(3-param kiosk) — CREATE + UPDATE branchesTimePlanningWorkingHoursService.Index— adds*InSecondsto the model and forks the SumFlex re-accumulation loopTimePlanningPlanningService.Update— main compute + replay-forward loopTimePlanningPlanningService.UpdateByCurrentUserNam— main compute + replay-forward loopTests added
8 new tests in
PlanRegistrationHelperTests.cs:NettoHours_FlagOn_DerivedFromDateTimeDeltasInSecondsNettoHours_FlagOn_PauseDateTimeBeatsPauseIdFlexAndSumFlex_FlagOn_DerivedFromInSecondsChainSumFlex_FlagOn_NoPreceding_StartsAtZeroFlex_FlagOn_OverrideActive_UsesOverrideForChainPaiedOutFlex_FlagOn_DerivedFromInSecondsNettoHours_FlagOff_NewHelperNotInvoked(flag-off regression guard)Index_FlagOn_DerivedFieldsConsistent([Ignore]'d, fixture carve-out per Phases 0/1 pattern)No edits to existing tests.
Test plan
pn-server-testgreenpn-playwright-test (a)greenpn-playwright-test (b)greenpn-client-testgreenPlan
/home/rene/.claude/plans/parallel-twirling-balloon.md🤖 Generated with Claude Code